package client;

import additions.*;
import java.util.Enumeration;
import java.util.Vector;
import javax.swing.*;

public class ClientGUI extends javax.swing.JFrame {

    /** Creates new form ClientGUI */
    public ClientGUI() {
        super("Instant Messenger Client");
        initComponents();
        int LoginUser = 0;
        Vector Contacts = new Vector();

        //Could do with being moved to the btnLogin if possible
        LoginUser = additions.Database.Login("Jim", "Jim");
        additions.Database.GetContacts(LoginUser, Contacts);
        ListContacts.setListData(Contacts);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dLogReg = new javax.swing.JDialog();
        btnLogin = new javax.swing.JButton();
        btnRegister = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        lblUserName = new javax.swing.JLabel();
        lblPassword = new javax.swing.JLabel();
        txtUserName = new javax.swing.JTextField();
        lblRepPass = new javax.swing.JLabel();
        lblEmailAdd = new javax.swing.JLabel();
        btnConfirm = new javax.swing.JButton();
        btnCancelReg = new javax.swing.JButton();
        txtEmailAdd = new javax.swing.JTextField();
        pPassword = new javax.swing.JPasswordField();
        pRepPassword = new javax.swing.JPasswordField();
        DialogSearch = new javax.swing.JDialog();
        TextSearchStr = new javax.swing.JTextField();
        ButtonDoSearch = new javax.swing.JButton();
        PanelChats = new javax.swing.JPanel();
        TabpaneChat1 = new javax.swing.JTabbedPane();
        PanelChat1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        PanelList = new javax.swing.JPanel();
        ScrollChats = new javax.swing.JScrollPane();
        ListChats = new javax.swing.JList();
        PanelControls = new javax.swing.JPanel();
        ButtonLogin = new javax.swing.JButton();
        ButtonChat = new javax.swing.JButton();
        ButtonSearch = new javax.swing.JButton();
        ButtonDelete = new javax.swing.JButton();
        ScrollContacts = new javax.swing.JScrollPane();
        ListContacts = new javax.swing.JList();
        PanelMessage = new javax.swing.JPanel();
        ButtonSendMsg = new javax.swing.JButton();
        TextMessage = new javax.swing.JTextField();
        Menubar = new javax.swing.JMenuBar();
        MenuFile = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();

        dLogReg.setAlwaysOnTop(true);
        dLogReg.setResizable(false);

        btnLogin.setText("Login");
        btnLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLoginActionPerformed(evt);
            }
        });

        btnRegister.setText("Register");
        btnRegister.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegisterActionPerformed(evt);
            }
        });

        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        lblUserName.setText("User Name");

        lblPassword.setText("Password");

        lblRepPass.setText("Repeat Password");

        lblEmailAdd.setText("Email Address");

        btnConfirm.setText("Confirm");
        btnConfirm.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConfirmActionPerformed(evt);
            }
        });

        btnCancelReg.setText("Cancel");
        btnCancelReg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelRegActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dLogRegLayout = new javax.swing.GroupLayout(dLogReg.getContentPane());
        dLogReg.getContentPane().setLayout(dLogRegLayout);
        dLogRegLayout.setHorizontalGroup(
            dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dLogRegLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dLogRegLayout.createSequentialGroup()
                        .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblUserName)
                            .addComponent(lblPassword))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(pPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
                            .addComponent(txtUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)))
                    .addGroup(dLogRegLayout.createSequentialGroup()
                        .addComponent(btnLogin)
                        .addGap(18, 18, 18)
                        .addComponent(btnRegister)
                        .addGap(18, 18, 18)
                        .addComponent(btnCancel))
                    .addGroup(dLogRegLayout.createSequentialGroup()
                        .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblEmailAdd)
                            .addComponent(lblRepPass, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(txtEmailAdd, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
                            .addComponent(pRepPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)))
                    .addGroup(dLogRegLayout.createSequentialGroup()
                        .addComponent(btnConfirm)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE)
                        .addComponent(btnCancelReg)))
                .addContainerGap())
        );
        dLogRegLayout.setVerticalGroup(
            dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dLogRegLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblUserName)
                    .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblPassword)
                    .addComponent(pPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnLogin)
                    .addComponent(btnRegister)
                    .addComponent(btnCancel))
                .addGap(18, 18, 18)
                .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblRepPass, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pRepPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblEmailAdd)
                    .addComponent(txtEmailAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(dLogRegLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnConfirm)
                    .addComponent(btnCancelReg))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        ButtonDoSearch.setText("Search");
        ButtonDoSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonDoSearchActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout DialogSearchLayout = new javax.swing.GroupLayout(DialogSearch.getContentPane());
        DialogSearch.getContentPane().setLayout(DialogSearchLayout);
        DialogSearchLayout.setHorizontalGroup(
            DialogSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DialogSearchLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TextSearchStr, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ButtonDoSearch)
                .addContainerGap())
        );
        DialogSearchLayout.setVerticalGroup(
            DialogSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DialogSearchLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(DialogSearchLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(ButtonDoSearch, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(TextSearchStr, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout PanelChat1Layout = new javax.swing.GroupLayout(PanelChat1);
        PanelChat1.setLayout(PanelChat1Layout);
        PanelChat1Layout.setHorizontalGroup(
            PanelChat1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)
        );
        PanelChat1Layout.setVerticalGroup(
            PanelChat1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 385, Short.MAX_VALUE)
        );

        TabpaneChat1.addTab("tab1", PanelChat1);

        javax.swing.GroupLayout PanelChatsLayout = new javax.swing.GroupLayout(PanelChats);
        PanelChats.setLayout(PanelChatsLayout);
        PanelChatsLayout.setHorizontalGroup(
            PanelChatsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabpaneChat1, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
        );
        PanelChatsLayout.setVerticalGroup(
            PanelChatsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(TabpaneChat1, javax.swing.GroupLayout.DEFAULT_SIZE, 410, Short.MAX_VALUE)
        );

        ScrollChats.setViewportView(ListChats);

        ButtonLogin.setText("Login");
        ButtonLogin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonLoginActionPerformed(evt);
            }
        });

        ButtonChat.setText("Chat");

        ButtonSearch.setText("Search");
        ButtonSearch.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ButtonSearchActionPerformed(evt);
            }
        });

        ButtonDelete.setText("Delete");

        javax.swing.GroupLayout PanelControlsLayout = new javax.swing.GroupLayout(PanelControls);
        PanelControls.setLayout(PanelControlsLayout);
        PanelControlsLayout.setHorizontalGroup(
            PanelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelControlsLayout.createSequentialGroup()
                .addComponent(ButtonLogin, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ButtonChat, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ButtonSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 67, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ButtonDelete, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE))
        );
        PanelControlsLayout.setVerticalGroup(
            PanelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(ButtonSearch, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(ButtonDelete, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(PanelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(ButtonLogin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(ButtonChat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        ScrollContacts.setViewportView(ListContacts);

        javax.swing.GroupLayout PanelListLayout = new javax.swing.GroupLayout(PanelList);
        PanelList.setLayout(PanelListLayout);
        PanelListLayout.setHorizontalGroup(
            PanelListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PanelControls, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(ScrollContacts, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
            .addComponent(ScrollChats, javax.swing.GroupLayout.DEFAULT_SIZE, 266, Short.MAX_VALUE)
        );
        PanelListLayout.setVerticalGroup(
            PanelListLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelListLayout.createSequentialGroup()
                .addComponent(PanelControls, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ScrollChats, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ScrollContacts, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        ButtonSendMsg.setText("Send");

        javax.swing.GroupLayout PanelMessageLayout = new javax.swing.GroupLayout(PanelMessage);
        PanelMessage.setLayout(PanelMessageLayout);
        PanelMessageLayout.setHorizontalGroup(
            PanelMessageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelMessageLayout.createSequentialGroup()
                .addComponent(TextMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 337, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ButtonSendMsg))
        );
        PanelMessageLayout.setVerticalGroup(
            PanelMessageLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(ButtonSendMsg, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(TextMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
        );

        MenuFile.setText("File");

        jMenuItem1.setText("Connect");
        MenuFile.add(jMenuItem1);

        Menubar.add(MenuFile);

        setJMenuBar(Menubar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(PanelChats, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(PanelMessage, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PanelList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(PanelChats, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PanelMessage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGroup(layout.createSequentialGroup()
                .addComponent(PanelList, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(117, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed
        // Is this needing to be checked with the Login Details with the detabase aswell?
        // Need to close the window after a successful login
        // Or Display an error if incorrect
        additions.Database.Login( txtUserName.getText(), String.valueOf(pPassword.getPassword()) );
//        if()     Needs to check Login Details with detabase
//      {
            JOptionPane.showMessageDialog(null, "Login Successful");
            dLogReg.setVisible(false);   
//        }
//        else
//        {
//            JOptionPane.showMessageDialog(null, "Your User Name Or Password Is Incorrect");
//            pPassword.setText("");
//        }
}//GEN-LAST:event_btnLoginActionPerformed

    private void ButtonLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonLoginActionPerformed
        dLogReg.setSize(290, 150); // Sets Login/Register Dialog Size
        dLogReg.setVisible(true); // Sets Login/Register Dialog to visible
}//GEN-LAST:event_ButtonLoginActionPerformed

    private void ButtonSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonSearchActionPerformed
        DialogSearch.setSize(300, 80); // Sets Search Dialog Size
        DialogSearch.setVisible(true); // Sets Search Dialog to Visible
    }//GEN-LAST:event_ButtonSearchActionPerformed

    private void ButtonDoSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ButtonDoSearchActionPerformed
        // Performs a LookUp to the database
        System.out.println(additions.Database.LookupUser(TextSearchStr.getText()));
    }//GEN-LAST:event_ButtonDoSearchActionPerformed

    private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegisterActionPerformed
        dLogReg.setSize(290, 290); // Extends the Login/Register Dialog
    }//GEN-LAST:event_btnRegisterActionPerformed

    private void btnConfirmActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfirmActionPerformed
        // If both the Passwords match, send data to the database
        if( String.valueOf( pPassword.getPassword() ).compareTo( String.valueOf( pRepPassword.getPassword() ) ) == 0 )
        {
            additions.Database.Register( txtUserName.getText(), txtEmailAdd.getText(), String.valueOf( pPassword.getPassword() ) );
            JOptionPane.showMessageDialog(null, "Registration Complete");
            dLogReg.setSize(290, 150);
        }
        else // Does not send data to database, prompts for password again
        {
            JOptionPane.showMessageDialog(null, "The Passwords Do Not Match");
            pRepPassword.setText("");
        }
    }//GEN-LAST:event_btnConfirmActionPerformed

    private void btnCancelRegActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelRegActionPerformed
        // Resets Login/Register Dialog back to the initial state
        pRepPassword.setText("");
        txtEmailAdd.setText("");
        dLogReg.setSize(290, 150);
    }//GEN-LAST:event_btnCancelRegActionPerformed

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
        // Sets the Login/Register Dialog to not Visible clearing the text fields
        pPassword.setText("");
        txtUserName.setText("");
        dLogReg.setVisible(false);
    }//GEN-LAST:event_btnCancelActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        try {
            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
        } catch (Exception ex) {
            System.out.println(ex);
        }

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new ClientGUI().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ButtonChat;
    private javax.swing.JButton ButtonDelete;
    private javax.swing.JButton ButtonDoSearch;
    private javax.swing.JButton ButtonLogin;
    private javax.swing.JButton ButtonSearch;
    private javax.swing.JButton ButtonSendMsg;
    private javax.swing.JDialog DialogSearch;
    private javax.swing.JList ListChats;
    private javax.swing.JList ListContacts;
    private javax.swing.JMenu MenuFile;
    private javax.swing.JMenuBar Menubar;
    private javax.swing.JPanel PanelChat1;
    private javax.swing.JPanel PanelChats;
    private javax.swing.JPanel PanelControls;
    private javax.swing.JPanel PanelList;
    private javax.swing.JPanel PanelMessage;
    private javax.swing.JScrollPane ScrollChats;
    private javax.swing.JScrollPane ScrollContacts;
    private javax.swing.JTabbedPane TabpaneChat1;
    private javax.swing.JTextField TextMessage;
    private javax.swing.JTextField TextSearchStr;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnCancelReg;
    private javax.swing.JButton btnConfirm;
    private javax.swing.JButton btnLogin;
    private javax.swing.JButton btnRegister;
    private javax.swing.JDialog dLogReg;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JLabel lblEmailAdd;
    private javax.swing.JLabel lblPassword;
    private javax.swing.JLabel lblRepPass;
    private javax.swing.JLabel lblUserName;
    private javax.swing.JPasswordField pPassword;
    private javax.swing.JPasswordField pRepPassword;
    private javax.swing.JTextField txtEmailAdd;
    private javax.swing.JTextField txtUserName;
    // End of variables declaration//GEN-END:variables

}
